Wasmi C-API
Usage in a C Project
If you have a C project with which you want to use Wasmi, you can interface with Wasmi's C API:
Prerequisites
From the root of the Wasmi repository, run the following commands:
cmake -S crates/c_api -B target/c_api --install-prefix "$(pwd)/artifacts" &&
cmake --build target/c_api --target install
These commands will produce the following files:
artifacts/lib/libwasmi.{a,lib}
: The static Wasmi library.artifacts/lib/libwasmi.{so,dylib,dll}
: The dynamic (or shared) Wasmi library.artifacts/include/**.h
: The header files for interfacing with Wasmi from C or C++.
Usage in a Rust Project
If you have a Rust crate that uses a C or C++ library that uses Wasmi, you can link to the Wasmi C API as follows:
- Add a dependency on the
wasmi_c_api_impl
crate to yourCargo.toml
. Note that package name differs from the library name.
[]
= { = "0.35.0", = "wasmi_c_api_impl" }
- In your
build.rs
file, when compiling your C/C++ source code, add the Cwasmi_c_api
headers to the include path: